#!/bin/bash
#Ich habe hier was gescrieben
CR="$(printf '\r')"
# CR=""

# Erste Zeile lesen
read   REQUEST_METHOD    PATH_INFO    PROTOCOL

# Weitere Header ignorieren
while read zeile; do
  [ "$zeile" = "$CR" ] && break
done

# Eigene Header ausgeben
printf '%s\r\n' "HTTP/1.1 200 OK" "Content-Type: text/html" ""

# Antwortdokument
cat <<HEREDOC
<!DOCTYPE HTML>
<html>
  <head><title>Versuch</title></head>
  <body><h1>Hallo Mercury! $REQUEST_METHOD</h1></body>
  $( [ "$PATH_INFO" = /limits ] && ulimit -a |while read zeile; do
                                                echo "$zeile" "<br/>"
                                              done
   )
</html>
HEREDOC

exit 0
